package com.bytedance.frameworks.b.a;

import java.lang.ref.WeakReference;
import java.lang.reflect.Proxy;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

public final class a {
    private static HashMap<String, LinkedList<WeakReference<?>>> a = new HashMap();

    public static void a(Class arg4, Object arg5) {
        if (arg5 != null) {
            HashMap v1 = a;
            synchronized (v1) {
                if (a == null) {
                    a = new HashMap<>();
                }

                String v2 = arg4.getName();
                Object v0_1 = a.get(v2);
                if (v0_1 == null) {
                    v0_1 = new LinkedList();
                    a.put(v2, (LinkedList<WeakReference<?>>) v0_1);
                }

                ((LinkedList) v0_1).add(new WeakReference(arg5));
                return;
            }
        }
    }

    public static List a(Class arg4) {
        HashMap v2 = a;
        synchronized (v2) {
            if (a == null) {
                return null;
            } else {
                LinkedList<WeakReference<?>> v0_2 = a.get(arg4.getName());
                LinkedList v1 = new LinkedList();
                Iterator<WeakReference<?>> v3 = ((List) v0_2).iterator();
                while (v3.hasNext()) {
                    Object v02 = v3.next().get();
                    if (v02 == null) {
                        continue;
                    }
                    ((List) v1).add(v02);
                }
                return v1;
            }
        }
    }

    public static Object b(Class arg4) {
        return Proxy.newProxyInstance(arg4.getClassLoader(), new Class[]{arg4}, new b(arg4));
    }
}

